package w4156.idog.client;

import javax.naming.Context;
import javax.naming.InitialContext;

import w4156.idog.exception.DBexception;
import w4156.idog.model.User;
import w4156.idog.server.PlayerManagerBeanRemote;


public class MyTestClient {

	private void runTest() throws Exception {
		PlayerManagerBeanRemote playerManager;
		Context playerCtx;

		playerCtx = new InitialContext();
	    playerManager = (PlayerManagerBeanRemote) playerCtx.lookup("ejb/eBlackjack/PlayerManagerSLSB");

		System.out.println("Saving user ..... " );

		try {
			User user = new User();
			user.setName("ZH");
			user.setPassword("zh");
			user.setObjid(99999);
			int id = playerManager.createUser(user);
			System.out.println("Saving user successfully: " + id);
		} catch (Exception e) {
			e.printStackTrace();
			throw new DBexception("Failed to create user");
		}
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			MyTestClient cli = new MyTestClient();
			cli.runTest();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
